package www.dianbaozu.com.ui.server

import dagger.hilt.android.AndroidEntryPoint
import www.dianbaozu.com.R
import www.dianbaozu.com.databinding.ActivityImProxyBinding
import www.dianbaozu.com.ui.MainFragment
import www.dianbaozu.com.ui.my.PersonalDetailsFragment
import www.wen.com.common.lib.base.activity.BaseActivity
import www.wen.com.common.lib.extension.isExitNavFragment
import www.wen.com.common.lib.extension.resetIMStartDestination
import www.wen.com.common.lib.extension.resetStartDestination
import www.wen.com.common.lib.extension.toast
import www.wen.com.common.lib.util.ActivityManagerUtil

@AndroidEntryPoint
class IMProxyActivity : BaseActivity<ActivityImProxyBinding>() {
    private val type by lazy { intent.getIntExtra("type", 0) }

    override fun getLayout(): Int = R.layout.activity_im_proxy

    companion object {
        const val TYPE_CHANNEL_DETAIL = 0
        const val TYPE_PERSONAL_HOMEPAGE = 1
        const val TYPE_MY_PERSONAL_HOMEPAGE = 2
    }

    override fun initialize() {
        when (type) {
            TYPE_CHANNEL_DETAIL -> resetIMStartDestination(
                R.navigation.im_navigation,
                R.id.channelDetailFragment
            )

            TYPE_PERSONAL_HOMEPAGE -> resetIMStartDestination(
                R.navigation.im_navigation,
                R.id.personalHomepageFragment
            )

            TYPE_MY_PERSONAL_HOMEPAGE -> resetIMStartDestination(
                R.navigation.im_navigation,
                R.id.personalDetailsFragment2
            )
        }
    }

    override fun onBackPressed() {
        super.onBackPressed()
        if (isExitNavFragment(PersonalDetailsFragment::class.java)) {
            finish()
        }
    }

}